#product
#handles all product related stuff
from google.appengine.ext import db
 
class Product(db.Model):
	name = db.StringProperty(multiline=False)
	description = db.StringProperty(multiline=True)
	url = db.StringProperty(multiline=False)
  
	def find(_name):
  		product_query = db.GqlQuery("select * from Product where name = :name", name=_name)
		product = product_query.fetch(1)
		return product[0]
	find = staticmethod(find)
	
	def exists(_name):
	  		product_query = db.GqlQuery("select * from Product where name = :name", name=_name)
			product = product_query.fetch(1)
			try:
				product[0]
				return 1
			except IndexError:
				return 0
			
	find = staticmethod(exists)